<?php
namespace app\restaurant\model;

use app\BaseModel;
use think\facade\Db;

class RefundOrderGoods extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_restaurant_refund_order_goods';





    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:05
     * @功能说明:编辑
     */
    public function orderUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:06
     * @功能说明:列表
     */
    public function orderList($dis){

        $data = $this->alias('a')
                ->join('longbing_card_restaurant_order_goods b','a.order_goods_id = b.id')
                ->where($dis)
                ->field(['b.goods_name','b.goods_img','a.goods_num','b.norms','a.goods_price','a.refund_price','a.order_goods_id'])
                ->group('a.id')
                ->order('a.id desc')
                ->select()
                ->toArray();

        if(!empty($data)){

            foreach ($data as &$v){

                $arr = Db::name('longbing_card_restaurant_feeding_order')->where(['order_goods_id'=>$v['order_goods_id']])->column('title');

                $v['feeding_text'] =  !empty($arr)?implode('+',$arr):'';
            }

        }

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:43
     * @功能说明:详情
     */
    public function orderInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }














}